package com.deyou.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.deyou.Constants;
import com.deyou.R;
import com.deyou.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class InfoEditActity extends BaseActivity {

    @BindView(R.id.iv_left_back)
    ImageView ivLeftBack;
    @BindView(R.id.tv_mid_title)
    TextView tvMidTitle;
    @BindView(R.id.tv_right)
    TextView tvRight;
    @BindView(R.id.iv_right)
    ImageView ivRight;
    @BindView(R.id.edt_info)
    EditText edtInfo;

    private int inputType = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_info_edit_actity);
        ButterKnife.bind(this);
        initData();
        initView();
    }

    private void initData(){
        inputType = getIntent().getExtras().getInt("inputType");
    }

    private void initView(){
        switch (inputType){
            case Constants.EditInputTypeNick:
                tvMidTitle.setText("编辑昵称");
                break;
            case Constants.EditInputTypeIntro:
                tvMidTitle.setText("编辑个人简介");
                break;
            case Constants.EditInputTypeHobby:
                tvMidTitle.setText("编辑兴趣爱好");
                break;
            default:
                tvMidTitle.setText("编辑");
                break;
        }
        tvRight.setText("确定");
        tvRight.setVisibility(View.VISIBLE);
        ivRight.setVisibility(View.GONE);

    }

    @OnClick({R.id.iv_left_back, R.id.tv_right})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_left_back:
                finish();
                break;
            case R.id.tv_right:
                Intent intent = new Intent();
                intent.putExtra("inputValue", edtInfo.getText().toString());
                setResult(RESULT_OK, intent);
                finish();
                break;
        }
    }
}
